﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using Entities;
using Sales.DataAccess.DO;

namespace Sales.WebAPI.Controllers
{
    public class StaffController : ApiController
    {
        private StaffDO StaffDO;

        public StaffController()
        {
            StaffDO = new StaffDO();
        }
        
        // GET api/values
        public IEnumerable<Staff> Get()
        {
            return StaffDO.GetAll();
        }

        // GET api/values/5
        public Staff Get(int id)
        {
            return StaffDO.GetSingle(cus => cus.SID == id);
        }

        // POST api/values
        public void Post(Staff staff)
        {
            StaffDO.Add(staff);
        }

        // PUT api/values/5
        public void Put(int id, Staff staff)
        {
            staff.SID = id;
            StaffDO.Update(staff);
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
            var staff = StaffDO.GetSingle(cus => cus.SID == id);
            StaffDO.Remove(staff);
        }

    }
}
